﻿#include "Vec3.h"
#include "../Misc.h"

namespace Base {
	Vec3 Vec3::operator/(float scalar) const {
		if (scalar == 0) {
			Debug::ThrowOrMessageBox("scalar is 0!");
		}
		return Vec3(x / scalar, y / scalar, z / scalar);
	}
	Vec3& Vec3::Normalize() {
		float len = Length();
		if (len == 0)
		{
			Debug::ThrowOrMessageBox("向量长度为 0!");
		}
		float inv = 1.0f / len;
		x *= inv;
		y *= inv;
		z *= inv;
		return *this;
	}


	Vec3 operator-(const Vec3& rhs) {
		return Vec3(-rhs.x, -rhs.y, -rhs.z);
	}
	Vec3 operator*(float scalar, const Vec3& rhs) {
		return Vec3(scalar*rhs.x, scalar*rhs.y, scalar*rhs.z);
	}
}